package cobersky.skinUI.components
{
	import cobersky.skinUI.skins.bar.DefaultHBarSkin;
	
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;

	public class HBar extends BarBase
	{
		public function HBar()
		{
			dragRect=new Rectangle(0,0,100,0);
		}
		override public function create():void{
			if(!_skinClass)_skinClass=DefaultHBarSkin;
			attachSkin();
		}
		override public function set width(value:Number):void
		{
			this._back.width=value;
			this.dragRect.width=value-_thumb.width;
		}
		
		override protected function onMove(event:MouseEvent):void
		{
			value=_thumb.x/(_back.width-_thumb.width);
			super.onMove(event);
		}
		
		override protected function moveThumb():void
		{
			_thumb.x=value*(_back.width-_thumb.width);
			super.moveThumb();
		}
		override protected function backClick():void
		{
			value=(mouseX-_thumb.width*.5)/(_back.width-_thumb.width);
			super.backClick();
		}
	}
}